package com.zbszkj.demo.agent;

import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;

import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class ZbszkjAgent {

    /**
     * 约定的方法名字，不能改
     * @param args
     * @param instrumentation
     */
    public static void premain(String args, Instrumentation instrumentation){
        System.out.println("Agent before invoke");
        
//        ClassFileTransformer transformer = new PerformMonitorTransformer();
//        instrumentation.addTransformer(transformer);

        Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new Runnable() {
            public void run() {
                JVMInfo.printMemoryInfo();
                JVMInfo.printGCInfo();
            }
        }, 0, 2000, TimeUnit.MILLISECONDS);

    }

}
